home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / goserv.zip / GOSERVE.DOC < prev    next >
Text File  |  1993-05-12  |  23KB  |  509 lines

  1.                                                                GoServe 1.00
  2. GoServe -- A Gopher Server for OS/2 2.x
  3. """""""""""""""""""""""""""""""""""""""
  4.  
  5. Copyright (c) International Business Machines Corporation, 1993.
  6. All rights reserved.
  7.  
  8.  
  9. Introduction
  10. """"""""""""
  11. 'Gopher' is a client-server protocol designed for text location and
  12. retrieval.  It was designed at the University of Minnesota, and is
  13. widely used; both clients and servers exist for most significant
  14. operating systems.  The Gopher protocol is described in documents
  15. distributed by the University of Minnesota Microcomputer and Workstation
  16. Networks Center.
  17.  
  18. 'GoServe' is a Gopher server for OS/2.  It is assumed that the reader is
  19. familiar with Gopher concepts, and has access to a Gopher client.
  20.  
  21. GoServe allows processing of a variety of Gopher requests, using a
  22. simple REXX filter to allow for customization.  Multiple servers can be
  23. started (using different ports), and an audit trail of requests and
  24. actions can be recorded.
  25.  
  26. While running, a Presentation Manager display of GoServe activity is
  27. shown.  For control, a limit may be placed on the number of concurrent
  28. requests that will be handled (hence limiting the load on the server
  29. machine).  Similarly, timeouts may be set to close connections after a
  30. chosen total or inactive time.  Certain GoServe operations can be
  31. controlled remotely, if desired, using any Gopher client (or a utility
  32. OS/2 program or CMD file).
  33.  
  34. Goserve is a 32-bit OS/2 application.  It requires TCP/IP for OS/2 to be
  35. installed and operational (either on a real network or using the
  36. loopback driver).
  37.  
  38. -----------
  39.  
  40. Mike Cowlishaw, IBM UK Laboratories
  41.  
  42.  
  43. How GoServe is used
  44. """""""""""""""""""
  45. When GoServe is started, it sets up a TCP/IP socket on port 70 (this is
  46. the 'well-known' port for Gopher, but can be changed--see below), then
  47. waits for requests from clients.  When a request from a Gopher client
  48. arrives, it is recorded in the audit file (if desired) and then the
  49. GoServe filter for the port is called.
  50.  
  51. The GoServe filter is a program written in REXX, which is given details
  52. of the client and the selector string or strings.  The filter locates
  53. the information (usually a file, containing a menu or a document) to be
  54. sent to the client, and returns details to GoServe.  GoServe then sends
  55. the data to the client and closes the TCP/IP connection.
  56.  
  57. Each incoming request is given a new thread for communication, filter
  58. processing, and response.  GoServe handles all the details of threads
  59. and TCP/IP communications, so the installer need only be concerned with
  60. the filter (which can be very simple) and the data (menus and
  61. documents).
  62.  
  63.  
  64. Installation
  65. """"""""""""
  66. Only two files (plus data) are needed to run GoServe: the GOSERVE.EXE
  67. program file, and the REXX filter.  The filter must have filename
  68. GOFILTER, with an extension that is the TCP/IP port number to be used
  69. (for example, 'GOFILTER.70' for the filter for the default Gopher port).
  70.  
  71. It is recommended that GOSERVE.EXE and the REXX filter be placed in one
  72. directory (for example, 'D:\GoServe'), and data for the server be placed
  73. in another (for example, 'D:\GoData70') or its subdirectories.  The REXX
  74. filter should be in the working directory for GoServe, and any audit
  75. file will be written to that directory.
  76.  
  77. The following files are included:
  78.  
  79.    goserve.doc  -- this document
  80.    goserve.exe  -- the server program
  81.    gofilter.70s -- sample filter (rename or copy as GOFILTER.70)
  82.    gosmenu.cmd  -- menu maker utility (see below)
  83.  
  84. TCP/IP 1.2.1 (or later) must be installed; the "0.0024" CSD (or later)
  85. for TCP/IP is required for most versions and betas of OS/2 2.x.  Over
  86. time, other CSDs may become available--if TCP/IP problems are suspected,
  87. always try the latest CSD.
  88.  
  89.  
  90. Filter programs
  91. """""""""""""""
  92. Filter programs are written in REXX.  Based on the arguments they are
  93. passed, they decide on the menu or document to be sent to the client and
  94. then return a result that defines that data to the server.
  95.  
  96. Three argument strings are passed to the filter:
  97.  
  98. 1. The source of the request.  This has four words [more words could be
  99.    added at the end in the future], separated by one or more blanks:
  100.  
  101.    a) the Internet address (primary host identifier) of the server's
  102.       machine or cluster (in numeric form)
  103.  
  104.    b) the server's port number used for the connection
  105.  
  106.    c) the transaction number (a number, incremented for each new
  107.       request, that starts at 0 when GoServe is started)
  108.  
  109.    d) the Internet address of the client (in numeric form).
  110.  
  111.    Example: "9.15.11.189 70 101 9.20.25.65"
  112.  
  113. 2. The selector string.  If this is an empty string, it is the
  114.    initial contact from a client, and the filter would normally respond
  115.    with a main menu.  Otherwise, it will (or should) be the selector
  116.    string from a Gopher menu line previously sent to the client,
  117.    unchanged.
  118.  
  119.    You have complete freedom in setting selector strings in menus, and
  120.    deciding how the filter should respond depending on the string
  121.    received.  Often, the name of a file is used, and that file is sent
  122.    to the client.  [Note: it is recommended that fully qualified
  123.    filenames NOT be used for selector strings.]
  124.  
  125. 3. The extended selector string.  Some Gopher clients can add additional
  126.    information to a request, attached to the selector string after a
  127.    Tab character.  GoServe discards the Tab character and presents the
  128.    remainder as the third argument to the filter.  See the Gopher
  129.    protocol documents for more information on how the extended selector
  130.    string is used.
  131.  
  132. The filter can specify that GoServe send either a file or a single
  133. string to the client, or request certain other GoServe operations. This
  134. is done by returning a result string to GoServe.  This string takes one
  135. of several forms (in which keywords and file specifications may be in
  136. lower, upper, or mixed case):
  137.  
  138. 1. FILE [ERASE] [BINARY] NAME filespec
  139.  
  140.    The file named by 'filespec' will be sent to the client.  'filespec'
  141.    should normally be a fully qualified name (if it is not, GoServe will
  142.    look for it in its working directory).  It may not include an
  143.    'upwards reference' sequence ("..\"), as these could allow clients
  144.    access to any file on the server machine.
  145.  
  146.    Either or both the optional keywords may be specified, in any order,
  147.    and have the following effects:
  148.  
  149.    ERASE  -- the file is a temporary file, and should be erased after
  150.              being sent.  [The transaction number can be used for
  151.              generating a safe name for a temporary file.]
  152.  
  153.    BINARY -- the file is a binary file; after sending, no Gopher
  154.              terminator line will be sent (and any trailing DOS
  155.              end-of-file character will not be stripped off).  GoServe
  156.              will close the TCP/IP connection as soon as the complete
  157.              file has been sent.
  158.  
  159. 2. STRING string
  160.  
  161.    The single string is returned to the client [along with added final
  162.    carriage return, etc., as demanded by the Gopher protocol].  This can
  163.    be used to return a simple message to the client.  Multiple lines can
  164.    be sent, if necessary, by embedding a CR-LF sequence to separate
  165.    lines.  A CR-LF is not needed at the end of the string.
  166.  
  167. 3. CONTROL options
  168.  
  169.    A GoServe action (such as requesting statistics, resetting counters,
  170.    or moving the audit file) is initiated.  This is used for controlling
  171.    the GoServe server from a remote client or from another process on
  172.    the same machine--for details, see the section "Remote control of
  173.    GoServe".
  174.  
  175.    A document is returned, indicating success or failure of the request.
  176.    Invalid options on CONTROL are not considered a failure of the filter.
  177.  
  178. 4. Null string/no string
  179.  
  180.    If a null string, or no string, is returned by the filter, a one-line
  181.    "no information available" document is sent to the client.
  182.  
  183. Any other response from the filter is not allowed; for safety, any
  184. failure of the filter is considered catastrophic and will cause GoServe
  185. to end.
  186.  
  187. Here is an example of a 'minimal' filter, GOFILTER.70:
  188.  
  189.   /* Sample GoServe filter program */
  190.   parse arg source, selector, selector2                   /* Get arguments */
  191.   parse var source server port transaction who .           /* Often useful */
  192.  
  193.   drive='d:'                                                 /* Data drive */
  194.   dir=drive'\godata'port'\'   /* Data root directory (e.g. "d:\godata70\") */
  195.  
  196.   /* This very simple filter just builds the full path name of a file from */
  197.   /* the selector and returns that.  Note we do not put the full path in   */
  198.   /* menus, as this could allow clients to access all files on the server  */
  199.   /* machine, which is rarely desirable.                                   */
  200.  
  201.   if selector='' then selector='mainmenu.'port           /* 'startup' case */
  202.   return 'File name' dir''selector
  203.  
  204. Notes:
  205.  
  206. 1. Remember that GoServe can run multiple copies of the filter at once,
  207.    if more than one client connects at the same time.
  208.  
  209. 2. The results of SAY instructions (or tracing) in the filter program may
  210.    be seen using the PMprintf package.
  211.  
  212. 3. You can execute OS/2 commands from the filter using the Address CMD
  213.    instruction, for example:
  214.  
  215.      address cmd
  216.      'start e foo.bar'
  217.      'call d:\foobar\test.cmd argstring'
  218.  
  219.    Use caution when calling external programs: any slowness directly
  220.    affects the response time to the client and its user.
  221.  
  222.  
  223. Running GoServe
  224. """""""""""""""
  225. GoServe may be started in any of the usual ways, such as from an OS/2
  226. command line or from a Program Reference object.  By default, GoServe
  227. uses the standard Gopher port (port 70).
  228.  
  229. Once GoServe has started, a PM window should appear.  If the window is
  230. large enough, it will include at the top a bar display that shows any
  231. client activity (the full width of the bar corresponds to the maximum
  232. number of clients allowed).  A half-height grey bar indicates the peak
  233. activity seen since GoServe was started.  This may be reset to zero by
  234. selecting 'Reset peak indicator' from the 'Options' menu, and will be
  235. shown in purple if any errors have been counted.
  236.  
  237. The second line of the window gives the total number of transactions
  238. initiated since GoServe started, and the count of errors that have
  239. occurred (if more than zero).  If room, it shows on the right the
  240. instantaneous count of connected clients and the peak number recorded
  241. since GoServe started (if more than one).  The transaction count may be
  242. reset to zero by selecting 'Reset transaction count' from the 'Options'
  243. menu).  Similarly, the error count and peak count may also be reset to
  244. zero.
  245.  
  246. The third line shows the number of bytes, thousands of bytes, or
  247. millions of bytes sent and received since GoServe started.  These counts
  248. may be reset to zero by selecting 'Reset byte counts' from the 'Options'
  249. menu.  The 'Options' menu also offers 'Reset all counts', which resets
  250. all of the counters.
  251.  
  252. Some or all of these items will be omitted if the window is too small
  253. for satisfactory display.  You can get more in a small GoServe window by
  254. clicking on 'Use menu bar' on the 'Options' menu--this will remove the
  255. menu bar from the display.  To use the menu after it has been removed,
  256. click anywhere on the GoServe window with mouse button 2, in the usual
  257. Workplace Shell manner (this works even if the menu bar is visible).
  258.  
  259. Two other menu options are supplied: 'Audit selection' lets you control
  260. the auditing of transactions, and 'Limits selection' is used to control
  261. the operating limits of the server.  These are described later.
  262.  
  263. The default port number [70] may be changed for special applications by
  264. using the PORT parameter when starting GoServe, for example:
  265.  
  266.   start goserve port 71
  267.  
  268. Servers started with different ports are independent; they use different
  269. filter programs, and maintain a different collection of settings, window
  270. position information, audit file, etc.
  271.  
  272. Note that the port number is used as the required file extension for
  273. some files--for port numbers greater than 999 you must therefore be sure
  274. that the working directory for GoServe is on a disk that supports
  275. extensions of more than three characters (for example, an HPFS disk).
  276.  
  277. GoServe also accepts two experimental keyword parameters.  'TRACE'
  278. copies audit information to the PMprintf window (without GoServe
  279. timestamps); this does not affect auditing to the audit file (see
  280. below).  'DIAG' shows TRACE information together with additional details
  281. of GoServe operation (also using PMprintf).  This diagnostic information
  282. is intended for development use and may change over time.
  283.  
  284.  
  285. The limits selection dialog
  286. """""""""""""""""""""""""""
  287. The 'Limits selection' dialog lets you change the maximum number of
  288. clients allowed concurrently [default 10], and the percentage at which
  289. the bar chart will show a red warning indicator [default 75%].  It also
  290. lets you change various timeout values.
  291.  
  292. The first two timeout settings control the time at which any uncompleted
  293. response may be terminated automatically by GoServe's "watchdog" thread.
  294.  
  295. The first timeout setting is the 'inactive timeout', in seconds; after
  296. at least the specified time without any data being sent or received the
  297. connection will be closed [default 60 seconds].  The second is the
  298. 'total timeout', in seconds; after at least the specified time the
  299. connection will be closed, even if there appears to be activity [default
  300. 600 seconds].  This value must not be less than the 'inactive' timeout.
  301.  
  302. For either timeout, a value of zero seconds may be specified to indicate
  303. an indefinite time (that is, the timeout check is not made).  You should
  304. only set both timeouts to zero if the filter is trusted, the data it
  305. accesses is always available locally, and all clients used with the
  306. server have a timeout mechanism.
  307.  
  308. Finally, a third timeout, the 'start timeout', specifies the time in
  309. seconds for which GoServe will wait on startup for TCP/IP to become
  310. operational, retrying appropriate TCP/IP calls as necessary [default 600
  311. seconds].  This allows asynchronous starting of TCP/IP and GoServe.
  312. Here, a value of 0 seconds means immediate timeout (that is, no retrys
  313. are performed, and GoServe will not start if an error is found).
  314.  
  315. No retry is attempted if the requested port is in use (that is, it is
  316. likely that another copy of GoServe is already running).
  317.  
  318.  
  319. The audit mechanism
  320. """""""""""""""""""
  321. GoServe includes a built-in audit mechanism that records events in an
  322. audit file while Goserve is running.  This maintains a record of usage,
  323. and also records any errors or failures of the server.
  324.  
  325. By default, all audit information (see details below) except selectors
  326. is recorded.  Choose the 'Audit selection' menu item (under 'Options')
  327. for a dialog that gives you detailed control over the content of the
  328. audit file.  You should only select auditing of 'Selectors' if the
  329. recording of selectors would not compromise confidentiality or privacy.
  330.  
  331. The audit file has a fixed filename (GOAUDIT), with an extension that is
  332. the TCP/IP port number used (for example, 'GOAUDIT.70').  It is written
  333. in the working directory for GoServe.  It may be read but not altered
  334. while GoServe is running.
  335.  
  336. Each line in the audit file starts with three words, separated by one or
  337. more blanks: the time (hhmmss), the audit type (one character), and the
  338. transaction number (a number, incremented for each request accepted,
  339. that begins at 0 when GoServe is started).  Additional information
  340. follows, depending on the audit type:
  341.  
  342.   A (Accept)      - the numeric TCP/IP address of the client (n.n.n.n)
  343.   C (Complete)    - transaction time (secs), and description of action
  344.   D (Day)         - the current day (yyyymmdd), and description of audit
  345.   E (Error)       - description of an error in processing (e.g., timeout)
  346.   F (Failure)     - description of the failure (terminating error)
  347.   I (Information) - description of information (statistics, etc.)
  348.   P (Port)        - server identity and port (n.n.n.n nn)
  349.   S (Selector)    - selector received from client
  350.  
  351. The format of any "description" in the above is not strictly defined.
  352. Additional audit types may be added later.
  353.  
  354. For example:
  355.  
  356.   151717 D 0 19930512 ----- GoServe 1.00 -----
  357.   151717 P 0 9.20.5.59 70
  358.   151730 A 1 9.20.5.59
  359.   151730 S 1
  360.   151731 C 1 0.55 Sent file "d:\godata70\mainmenu.70"
  361.   151733 A 2 9.20.5.59
  362.   151733 S 2 about.doc
  363.   151734 C 2 0.2 Sent file "d:\godata70\about.doc"
  364.   151931 I 2 Bytes sent 99 received 11
  365.   151931 I 2 Close
  366.  
  367. The transaction time recorded on 'C' lines is rounded to the nearest
  368. 50ms, and measures the total elapsed time from receiving the request to
  369. complete delivery of the data.  This depends on the speed and activity
  370. of the server, client, and the network between the two.  It is likely to
  371. be rather variable.
  372.  
  373. To look at an 'active' log file, use a program or command that allows
  374. shared reading of files.  TYPE is one such command; its output may be
  375. redirected to a file to take a snapshot copy of the log.  For example:
  376.  
  377.   type goaudit.70 > snapshot.log
  378.  
  379. In addition, the 'Options' pull down menu has an item 'Move audit to
  380. archive'.  This closes the audit file, appends it to the GoServe archive
  381. file in the current working directory, then erases and re-opens the
  382. audit file.  The GoServe filter can also initiate this action, by
  383. returning "control moveaudit"--see elsewhere for details.
  384.  
  385. The GoServe archive file has a fixed filename (GOARCH), with an
  386. extension that is the TCP/IP port number used (for example,
  387. 'GOARCH.70').  It is only touched by GoServe during a "Move audit to
  388. archive", so is readily copied, edited, or renamed.
  389.  
  390.  
  391. GOSMENU.CMD
  392. """""""""""
  393. The GoServe package includes a simple utility that makes it easier to
  394. create 'canonical' Gopher menu files.  See the start of GOSMENU.CMD for
  395. details.  A 'menu template' file, perhaps called MAINMENU.MEN, might
  396. look like this:
  397.  
  398.   Sample main menu
  399.   ; rexx.central.edu 70
  400.   0 About this Gopher server; about.doc
  401.   1 IBM Almaden Gopher server;; almaden.gopher.ibm.com
  402.   1 Interesting stuff; interest.70
  403.  
  404. The first line is a description; the second gives the field separator
  405. character (which will become Tab in the generated menu), together with
  406. the default server address and port.  Subsequent lines are menu lines,
  407. as required by the Gopher protocol.  Lines whose first character is a
  408. blank are ignored (that is, they are not included in the menu file).
  409.  
  410. Running GOSMENU against this file (with a different output filename)
  411. like this:
  412.  
  413.   gosmenu mainmenu.men mainmenu.70
  414.  
  415. will create a 'canonical' menu file, with real tab characters instead of
  416. semicolons, address and port added where required, and extra blanks
  417. removed.  The Gopher protocol suggests that the first (description)
  418. field be no more than 70 characters, and requires that the entire menu
  419. line (including address and port) fit within 255 characters.
  420.  
  421. Notes:
  422.  
  423. 1. The default output filename for GOSMENU.CMD is constructed by replacing
  424.    the extension of the input filename by '70', so the sample command could
  425.    have been simply:
  426.  
  427.      gosmenu mainmenu.men
  428.  
  429.    Or, of course, the file MAINMENU.MEN could have been dropped on a
  430.    Program Reference object that starts GOSMENU.CMD
  431.  
  432. 2. It is recommended that 'active' menu files be identified by an extension
  433.    which is the Gopher port for which they are to be used.
  434.  
  435.  
  436. Remote control of GoServe
  437. """""""""""""""""""""""""
  438. GoServe filters (see "Filter programs") can request that GoServe perform
  439. certain actions, instead of just returning files or other data.  These
  440. requests may be used to control GoServe remotely (from another machine
  441. or from another process on the same machine).  All requests return a
  442. document of one or more lines, either showing successful completion of
  443. the request or indicating an error.
  444.  
  445. Specifically, if the filter response string begins with the verb
  446. "CONTROL", then the remainder (after one or more blanks) may take one
  447. of several forms:
  448.  
  449. 1. SAY text
  450.  
  451.    This is a simple "loopback" test: the specified text is returned to
  452.    the sender as a document.
  453.  
  454. 2. STATISTICS
  455.  
  456.    Current statistics and settings are returned as a document.  These
  457.    include:
  458.  
  459.    * Transaction, error, byte, and client counts
  460.  
  461.    * Settings (not including for audit selections)
  462.  
  463.    * The local time of certain events (if an event has not occurred, it
  464.      is shown as the GoServe start time).
  465.  
  466.    [The exact format of these statistics could change in the future.]
  467.  
  468. 3. RESET [BYTES] [PEAK] [TRANSACTIONS] [ERRORS] [ALL]
  469.  
  470.    The specified GoServe counters and statistics are reset (after
  471.    auditing, if appropriate).  Any or all of the keywords may be given,
  472.    in any order.  Each works in the same way as the corresponding menu
  473.    pull-down.
  474.  
  475. 4. MOVEAUDIT
  476.  
  477.    The audit file is copied to the archive file (just as though the
  478.    'Move audit to archive' menu item had been selected).
  479.  
  480. The filter mechanism provides flexibility in how these requests are
  481. accepted and passed to GoServe.  For example, to accept control requests
  482. (here identified by a selector that starts with '!') only from certain
  483. addresses, the last two lines in the sample filter in "Filter programs"
  484. could be replaced with:
  485.  
  486.   if left(selector,1)<>'!' then do        /* this is not a control request */
  487.     if selector='' then selector='mainmenu.'port         /* 'startup' case */
  488.     return 'File name' dir''selector               /* normal selector case */
  489.     end
  490.   /* this is a control request */
  491.   owners=server 19.112.45.7                /* list of authorized addresses */
  492.   if wordpos(who, owners)=0 then return    /* ignore unauthorized requests */
  493.   return 'control' substr(selector,2)    /* remainder of string is request */
  494.  
  495. A control menu for issuing control requests might include lines like
  496. these (prior to processing with GOSMENU.CMD):
  497.  
  498.   0 Show statistics;       !statistics
  499.   0 Move audit to archive; !moveaudit
  500.   0 Test loopback;         !say Hello world!
  501.   0 Reset all;             !reset all
  502.   0 Reset peak count;      !reset peak
  503.   0 Reset byte counts;     !reset bytes
  504.   0 Reset error count;     !reset errors
  505.   0 Reset transactions;    !reset transactions
  506.  
  507. The filter could be further modified so that only clients with
  508. authorized addresses would see a menu with these options.
  509.